package com.wanmait.gohome.controller.web;

import com.wanmait.gohome.pojo.Userinfo;
import com.wanmait.gohome.service.AttentionService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/web/attention")
public class AttentionController {
    @Resource
    private AttentionService attentionService;


    /**
     *
     * @param request  关注
     */
    @GetMapping("attention")
    @ResponseBody
    public String Attention(HttpServletRequest request, Integer informationId)
    {
        Userinfo userinfo = (Userinfo)request.getSession().getAttribute("userinfo");
        if(userinfo==null){
            request.getSession().setAttribute("goUrl","/GoHome/web/information/showList?id="+informationId);
            return "login";
        }else{
            attentionService.insert(userinfo.getId(),informationId);
            return "ok";
        }

    }
}
